/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DialogGain.java
 *
 * Created on Jul 25, 2010, 4:00:17 PM
 */
package botoseis.iview.dialogs;


//  Gtk::CheckButton m_panel;
//  Gtk::CheckButton m_agc;
//  Gtk::CheckButton m_gagc;
//  Gtk::CheckButton m_qbal;
//  Gtk::CheckButton m_pbal;
//  Gtk::CheckButton m_mbal;
//  Gtk::CheckButton m_maxbal;
//  Gtk::CheckButton m_jon;
/**
 *
 * @author gabriel
 */
public class DialogGain extends javax.swing.JDialog {

    /** Creates new form DialogGain */
    public DialogGain(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        cbPanel = new javax.swing.JCheckBox();
        cbAgc = new javax.swing.JCheckBox();
        cbGagc = new javax.swing.JCheckBox();
        cbQbal = new javax.swing.JCheckBox();
        cbPbal = new javax.swing.JCheckBox();
        cbMbal = new javax.swing.JCheckBox();
        cbMaxbal = new javax.swing.JCheckBox();
        cbJon = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        tfTpow = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        tfClip = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tfEpow = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        tfGclip = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tfGpow = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tfScale = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfWagc = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        tfNorm = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        tfTrap = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        tfBias = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new java.awt.GridLayout(1, 0));

        jPanel1.setLayout(new java.awt.BorderLayout());

        jPanel2.setPreferredSize(new java.awt.Dimension(382, 50));
        jPanel2.setLayout(new java.awt.GridLayout(2, 4));

        cbPanel.setText("panel");
        jPanel2.add(cbPanel);

        cbAgc.setText("agc");
        jPanel2.add(cbAgc);

        cbGagc.setText("gagc");
        jPanel2.add(cbGagc);

        cbQbal.setText("qbal");
        jPanel2.add(cbQbal);

        cbPbal.setText("pbal");
        jPanel2.add(cbPbal);

        cbMbal.setText("mbal");
        jPanel2.add(cbMbal);

        cbMaxbal.setText("maxbal");
        jPanel2.add(cbMaxbal);

        cbJon.setText("jon");
        jPanel2.add(cbJon);

        jPanel1.add(jPanel2, java.awt.BorderLayout.PAGE_START);

        jPanel3.setPreferredSize(new java.awt.Dimension(306, 80));
        jPanel3.setLayout(new java.awt.GridLayout(2, 0));

        jButton1.setText("Reset to default values");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton1);

        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton2);

        jButton3.setText("Apply");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton3);

        jPanel3.add(jPanel5);

        jPanel1.add(jPanel3, java.awt.BorderLayout.PAGE_END);

        jPanel4.setPreferredSize(new java.awt.Dimension(306, 100));
        jPanel4.setLayout(new java.awt.GridLayout(5, 4));

        jLabel1.setText("tpow");
        jPanel4.add(jLabel1);

        tfTpow.setText("0");
        jPanel4.add(tfTpow);

        jLabel6.setText("clip");
        jPanel4.add(jLabel6);

        tfClip.setText("0");
        jPanel4.add(tfClip);

        jLabel2.setText("epow");
        jPanel4.add(jLabel2);

        tfEpow.setText("0");
        jPanel4.add(tfEpow);

        jLabel7.setText("gclip");
        jPanel4.add(jLabel7);

        tfGclip.setText("0");
        jPanel4.add(tfGclip);

        jLabel3.setText("gpow");
        jPanel4.add(jLabel3);

        tfGpow.setText("0");
        jPanel4.add(tfGpow);

        jLabel8.setText("scale");
        jPanel4.add(jLabel8);

        tfScale.setText("0");
        jPanel4.add(tfScale);

        jLabel4.setText("wagc");
        jPanel4.add(jLabel4);

        tfWagc.setText("0");
        jPanel4.add(tfWagc);

        jLabel9.setText("norm");
        jPanel4.add(jLabel9);

        tfNorm.setText("0");
        jPanel4.add(tfNorm);

        jLabel5.setText("trap");
        jPanel4.add(jLabel5);

        tfTrap.setText("0");
        jPanel4.add(tfTrap);

        jLabel10.setText("bias");
        jPanel4.add(jLabel10);

        tfBias.setText("0");
        jPanel4.add(tfBias);

        jPanel1.add(jPanel4, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        apply= true;
        dispose();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        tfEpow.setText("0.0");
        tfTpow.setText("0.0");
        tfGpow.setText("1.0");
        tfWagc.setText("0.5");
        tfTrap.setText("0.0");
        tfClip.setText("0.0");
        tfGclip.setText("1.0");
        tfScale.setText("1.0");
        tfNorm.setText("1.0");
        tfBias.setText("0.0");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
            apply = false;
            dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    public float getFloatValue(String parm) {
        if (parm.equals("tpow")) {
            return new Float(tfTpow.getText());
        } else {
            if (parm.equals("epow")) {
                return new Float(tfEpow.getText());
            } else {
                if (parm.equals("gpow")) {
                    return new Float(tfGpow.getText());
                } else {
                    if (parm.equals("wagc")) {
                        return new Float(tfWagc.getText());
                    } else {
                        if (parm.equals("trap")) {
                            return new Float(tfTrap.getText());
                        } else {
                            if (parm.equals("scale")) {
                                return new Float(tfScale.getText());
                            } else {
                                if (parm.equals("norm")) {
                                    return new Float(tfNorm.getText());
                                } else {
                                    if (parm.equals("bias")) {
                                        return new Float(tfBias.getText());
                                    } else {
                                        if (parm.equals("gclip")) {
                                            return new Float(tfGclip.getText());
                                        } else {
                                            if (parm.equals("clip")) {
                                                return new Float(tfClip.getText());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return 0f;
    }

    public boolean getBooleanValue(String parm) {
        if (parm.equals("panel")) {
            return cbPanel.isSelected();
        } else {
            if (parm.equals("jon")) {
                return cbJon.isSelected();
            } else {
                if (parm.equals("maxbal")) {
                    return cbMaxbal.isSelected();
                } else {
                    if (parm.equals("mbal")) {
                        return cbMbal.isSelected();
                    } else {
                        if (parm.equals("pbal")) {
                            return cbPbal.isSelected();
                        } else {
                            if (parm.equals("qbal")) {
                                return cbQbal.isSelected();
                            } else {
                                if (parm.equals("agc")) {
                                    return cbAgc.isSelected();
                                } else {
                                    if (parm.equals("gagc")) {
                                        return cbGagc.isSelected();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

 

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                DialogGain dialog = new DialogGain(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox cbAgc;
    private javax.swing.JCheckBox cbGagc;
    private javax.swing.JCheckBox cbJon;
    private javax.swing.JCheckBox cbMaxbal;
    private javax.swing.JCheckBox cbMbal;
    private javax.swing.JCheckBox cbPanel;
    private javax.swing.JCheckBox cbPbal;
    private javax.swing.JCheckBox cbQbal;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JTextField tfBias;
    private javax.swing.JTextField tfClip;
    private javax.swing.JTextField tfEpow;
    private javax.swing.JTextField tfGclip;
    private javax.swing.JTextField tfGpow;
    private javax.swing.JTextField tfNorm;
    private javax.swing.JTextField tfScale;
    private javax.swing.JTextField tfTpow;
    private javax.swing.JTextField tfTrap;
    private javax.swing.JTextField tfWagc;
    // End of variables declaration//GEN-END:variables

    private boolean apply;

    /**
     * @return the apply
     */
    public // End of variables declaration
    boolean isApply() {
        return apply;
    }

    /**
     * @param apply the apply to set
     */
    public void setApply(boolean apply) {
        this.apply = apply;
    }
}
